<?php

//print_r($_POST);
 
// username and password sent from form 


print_r($_POST);
//return;
$uid=$_POST['uid'];


$scan_code=$_POST['scan_code'];

$designer=$_POST['designer'];
$name=$_POST['name'];
$active=$_POST['active'];
$price=$_POST['price'];
$ratio=$_POST['ratio'];

	if(strlen($scan_code)==0){
		header("location:../index.php?page=manage_items&stat=error&error=badData");
    }elseif(isItemExist($scan_code)){
    	
    	header("location:../index.php?page=manage_items&stat=error&error=duplicated");
    }else{
    	if($_POST['option']=='scan_code'){
	    	if(createItem($scan_code,$designer,$name,$active,$price,$ratio)){
	    	header("location:../index.php?page=manage_items&stat=inserted");
				
	    	}else{
	    	header("location:../index.php?page=manage_items&stat=error&error=badData");
				
	    	}
    	}elseif($_POST['option']=='random'){
			if(createIgnoreItem($scan_code,$designer,$name,$active,$price,$ratio)){
	    	header("location:../index.php?page=manage_items&stat=inserted");
				
	    	}else{
	    	header("location:../index.php?page=manage_items&stat=error&error=badData");
				
	    	}
		
		}else{
	    	header("location:../index.php?page=manage_items&stat=error&error=badData");
		}
    	//header("location:../index.php?page=stack&id=".$Orid."&error=checkfail");
		
    }

  return ;

?>